//
//  QNCommonTool.h
//  QNReuseTool
//
//  Created by rsh on 2019/10/15.
//  Copyright © 2019年 rsh. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface QNCommonTool : NSObject<CAAnimationDelegate>


+ (void)loadingWithText:(NSString *)text andInView:(UIView *)view;

+ (void)hideLoadingView:(UIView *)view;


//用正则表达式判断输入的内容为8-16位且同时包含数字和字母
+(BOOL)judgePassWordLegal:(NSString *)pass;

//设置label行与行的间距
+(void)setLineSpaceWithLabel:(UILabel *)lb withSpace:(CGFloat)space;



// 字典转json字符串方法
+(NSString *)dictionaryConvertToJsonData:(NSDictionary *)dict;

//字典转json字符串方法，不去掉里面的换行符
+(NSString *)dictionaryToJsonStr:(NSDictionary *)dict;

//将字符串转成字典
+(NSDictionary *)parseJSONStringToNSDictionary:(NSString *)JSONString;


//设置颜色渐变并返回一个layer
+(CAGradientLayer *)colorLayer:(NSArray *)colors withLocations:(NSArray *)locations withStartPoint:(CGPoint)sPoint withEndPoint:(CGPoint)ePoint withSize:(CGSize)size;


+(void)addGradient:(CGRect)frame view:(UIView *)view fcolor:(UIColor *)fcolor scolor:(UIColor *)scolor;

/** 取消searchBar背景色 */
+ (UIImage *)imageWithColor:(UIColor *)color size:(CGSize)size;


//将11位电话号码13533441234 转换成 135***1234
+(NSString *)transPhoneNumWithString:(NSString *)str;

//将18位或者15位身份证号  转换成 4414***234X
+(NSString *)transIdNumWithString:(NSString *)str;



//解析JSON获取字典
+(NSDictionary *)getDictionaryWithJSONStr:(NSString *)jsonStr;

//解析JSON获取数组
+(NSArray *)getArrayWithJSONStr:(NSString *)jsonStr;

//根据省份证号获取年龄
+(NSString *)getIdentityCardAge:(NSString *)numberStr;

//图片转字符串
+(NSString *)UIImageToBase64Str:(UIImage *) image;

//字符串转图片
+(UIImage *)Base64StrToUIImage:(NSString *)encodedImageStr;

/**
 *
 *图片的压缩处理2步曲
 1）宽高均大于1280，取较大值等于1280，较大值等比例压缩
 2）宽或高一个大于1280，取较大的等于1280，较小的等比压缩
 3）宽高均小于1280，压缩比例不变
 *
 1）图片大于1M的，将压缩系数调整到0.7
 2）图片在0.5M<image<1M,将压缩系数调整到0.8
 3）图片小雨0.5M，压缩系数可以写0.9或者1
 **/
+(NSData *)zipNSDataWithImage:(UIImage *)sourceImage;

//颜色转换为背景图片
+ (UIImage *)imageWithColor:(UIColor *)color;

//加入购物车动画
+(void)animationWithView:(UIView *)view startCenter:(CGPoint)start finishCenter:(CGPoint)finish;

//跑马灯动画
+(void)addMarqueeAnimationWithView:(UIView *)view;

//计算字符串宽高
+ (CGSize)sizeWithFont:(UIFont*)font Str:(NSString*)str withMaxWidth:(CGFloat)maxWidth;

//URL字符串的URLencode
+(NSString*)encodeString:(NSString*)unencodedString;

//URLDEcode
+(NSString *)decodeString:(NSString*)encodedString;

//iOS设备是否越狱的判断代码
+(BOOL)isJailBreak;




@end
